home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / thor / edge / uuencode.edge < prev   
Text File  |  1996-11-10  |  3KB  |  108 lines

  1. /* UUEncode.edge
  2. ** $VER: UUEncode.edge v1.2    (27.12.96)
  3. ** Original script by Troels Walsted Hansen
  4. ** An ARexx script that uuencodes a file and imports it into the
  5. ** EDGE you are currently using. Unless the file is already
  6. ** archived this script will optionally do it for you (using LhA).
  7. **
  8. ** Utilizes LhA by Stefan Boberg and either of the following:
  9. **    · UUFast v1.25 by Jørn Halonen
  10. **    · uuIn v1.03 by Nicolas Dade
  11. **    · UUxT v3.1 by Asher Feldman
  12. **
  13. **  · proudly plagerized from THOR's archive ;^)
  14. */
  15.  
  16. /* some user variables. edit to your hearts content */
  17.  
  18. tmpdir = "T:"        /* Work dir for the encoding        */
  19. uuencoder = "uuxt"    /* may be: "uuin", "uufast" or "uuxt"    */
  20. uuprogpath = "C:"    /* Path to your uuencoder. This    path    */
  21.                     /* MUST end with either ':' or '/'.    */
  22.  
  23. /* do NOT edit below here unless you know what you're doing :-) */
  24.  
  25. options results
  26.  
  27. /* needs EDGE and bbsread.library functions */
  28.  
  29. if(substr(address(),1,4) ~= "EDGE") then
  30. do
  31.     say "This script should only be started from inside EDGE."
  32.     exit 20
  33. end
  34. else edgeport = address()
  35.  
  36. if ~show('p', 'BBSREAD') then
  37. do
  38.     address command
  39.         "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  40.         "WaitForPort BBSREAD"
  41. end
  42.  
  43. /* get filename */
  44.  
  45. address(bbsread)
  46. GETGLOBALDATA STEM GLOBALDATA
  47. address(edgeport)
  48. REQUESTFILE title '"Select file to encode:"' PATH GLOBALDATA.UPLOADPATH
  49. filetoencode=result
  50.  
  51. if(rc ~= 0) then exit
  52.  
  53. lastchar = right(filetoencode,1)
  54.  
  55. if(lastchar = "/" | lastchar = ":" | filetoencode = "") then
  56. do
  57.     REQUESTNOTIFY '"No file selected!"' TITLE '"Error"' result
  58.     signal exit
  59. end
  60.  
  61. posi = lastpos("/",FileToEncode)
  62. if(posi = 0) then posi = lastpos(":",FileToEncode)
  63. WithoutPath = substr(FileToEncode,posi+1)
  64.  
  65. /* if file isn't LhA'ed -- do it ourselves */
  66.  
  67. extension = upper(substr(FileToEncode, lastpos(".",FileToEncode)+1))
  68.  
  69. if~(extension = "LHA" | extension = "LZH") then
  70. do
  71.     REQUESTCHOICE TITLE 'UUEncode.edge' STRING 'Do you want to LhA the file?' result
  72.     if RC==0 then
  73.     do
  74.         address command "LhA >nil: -y -q a "||'"'tmpdir||WithoutPath'"'||" "||'"'FileToEncode'"'
  75.  
  76.         if(rc ~= 0) then REQUESTNOTIFY '"LhA''ing did not succeed."' TITLE '"UUEncode.edge"' result
  77.         else FileToEncode = tmpdir||WithoutPath||".lha"
  78.     end
  79. end
  80.  
  81. select
  82.     when(upper(uuencoder) = 'UUFAST')    then cmd = uuprogpath || 'UUFast >nil: ' || '"' || filetoencode || '"' || " TO " || tmpdir || "Message.uu E"
  83.     when(upper(uuencoder) = 'UUIN')        then cmd = uuprogpath || 'uuIn >nil: INFILE=' || '"' || filetoencode || '"' || " OUTFILE=" || tmpdir || "Message.uu"
  84.     when(upper(uuencoder) = 'UUXT')        then cmd = uuprogpath || 'UUxT >nil: a ' || tmpdir || 'Message.uu ' || '"'filetoencode'"'
  85.     otherwise
  86.     do
  87.         REQUESTNOTIFY '"UUEncoder not configured correctly."' TITLE '"UUEncode.edge"' result
  88.         signal exit
  89.     end
  90. end
  91. address command cmd
  92.  
  93. if ~exists(tmpdir"Message.uu") then
  94. do
  95.     REQUESTNOTIFY '"Something went wrong during uuencoding."' TITLE '"UUEncode.edge"' result
  96.     signal exit
  97. end
  98.  
  99. address(edgeport)
  100. INCLUDE '"' || tmpdir || 'Message.uu' || '"'
  101.  
  102. /* cleanup and exit */
  103.  
  104. exit:
  105.     if(exists(tmpdir || WithoutPath || ".lha")) then address command 'delete >nil: ' || '"' || tmpdir || WithoutPath || '.lha' || '"'
  106.     if(exists(tmpdir || "Message.uu")) then address command 'delete >nil: ' || tmpdir || 'Message.uu'
  107.     exit
  108.